package es.ucm.fdi.xtremeaudio.vista;

import java.awt.Color;
import java.awt.ComponentOrientation;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.border.LineBorder;

import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;

import es.ucm.fdi.xtremeaudio.controlador.Controlador;

/**
 * <ul>
 * <li><b>Proyecto:</b> XtremeAudio</li>
 * <li><b>Grupo:</b> 7 <i>(4&deg;B)</i></li>
 * <li><b>Asignatura:</b> Ingenier&iacute;a del Software</li>
 * <li><b>Curso:</b> 2010/2011</li>
 * <li><b>Centro:</b> Universidad Complutense de Madrid</li>
 * </ul>
 * 
 * El <b>FormTags</b> es el formulario que permite modificar los tags editables
 * de la canci&o;n que esté sonando actualmente.<br/>
 * <p>
 * <i><b>NOTA:</b> Omitimos los comentarios sobre los distintos componentes y
 * nos limitamos a comentar los m&eacute;todos relevantes</i>.<br/>
 * </p>
 * 
 * @author &Aacute;lvaro G&oacute;mez Porris
 * @author Elena Hern&aacute;ndez Delgado
 * @author Mar&iacute;a Trinidad Mart&iacute;n Campos
 * @author Mois&eacute;s Mart&iacute;nez Montes
 * @author Mat&iacute;as Salinero Delgado
 * 
 * @version %I%, %G%
 * 
 * @since 1.0
 */
public class FormTags {

	private static Integer alto;
	private static Integer ancho;
	private static Color colorBorde = new Color(255, 157, 92);

	public static Integer getAlto() {
		return alto;
	}

	public static Integer getAncho() {
		return ancho;
	}

	/**
	 * @return the colorBorde
	 */
	public static Color getColorBorde() {
		return colorBorde;
	}

	public static void setAlto(Integer alto) {
		FormTags.alto = alto;
	}

	public static void setAncho(Integer ancho) {
		FormTags.ancho = ancho;
	}

	/**
	 * @param colorBorde
	 *            the colorBorde to set
	 */
	public static void setColorBorde(Color colorBorde) {
		FormTags.colorBorde = colorBorde;
	}

	private JButton botonAceptar;
	private JButton botonCancelar;
	private JButton botonCerrar;
	private JButton botonMin;
	private JTextField fieldAlbum;
	private JTextField fieldAnyo;
	private JTextField fieldAutor;
	private JTextField fieldGenero;
	private JTextField fieldPista;
	private JTextField fieldTitulo;
	private JLabel labelAlbum;
	private JLabel labelAnyo;
	private JLabel labelAutor;

	private JLabel labelGenero;
	private JLabel labelLogo;
	private JLabel labelPista;

	private JLabel labelTitulo;

	private JPanelImagen panelBotones;

	private JPanelImagen panelSuperior;

	private JPanelImagen panelTags;

	private JPanel panelVentana;

	private JFrame ventana;

	/**
	 * Constructora por defecto.
	 */
	public FormTags() {
		initLookAndFeel();
		initComponents();
	}

	public JButton getBotonAceptar() {
		return botonAceptar;
	}

	public JButton getBotonCancelar() {
		return botonCancelar;
	}

	public JButton getBotonCerrar() {
		return botonCerrar;
	}

	public JButton getBotonMin() {
		return botonMin;
	}

	public JTextField getFieldAlbum() {
		return fieldAlbum;
	}

	public JTextField getFieldAnyo() {
		return fieldAnyo;
	}

	public JTextField getFieldAutor() {
		return fieldAutor;
	}

	public JTextField getFieldGenero() {
		return fieldGenero;
	}

	public JTextField getFieldPista() {
		return fieldPista;
	}

	public JTextField getFieldTitulo() {
		return fieldTitulo;
	}

	public JLabel getLabelAlbum() {
		return labelAlbum;
	}

	public JLabel getLabelAnyo() {
		return labelAnyo;
	}

	public JLabel getLabelAutor() {
		return labelAutor;
	}

	public JLabel getLabelGenero() {
		return labelGenero;
	}

	public JLabel getLabelLogo() {
		return labelLogo;
	}

	public JLabel getLabelPista() {
		return labelPista;
	}

	public JLabel getLabelTitulo() {
		return labelLogo;
	}

	public JPanelImagen getPanel() {
		return panelTags;
	}

	/**
	 * @return the panelBotones
	 */
	public JPanelImagen getPanelBotones() {
		return panelBotones;
	}

	public JPanelImagen getPanelSuperior() {
		return panelSuperior;
	}

	public JPanelImagen getPanelTags() {
		return panelTags;
	}

	public JPanel getPanelVentana() {
		return panelVentana;
	}

	public JFrame getVentana() {
		return ventana;
	}

	public void hide() {
		ventana.setVisible(false);
	}

	public void setBotonAceptar(JButton botonAceptar) {
		this.botonAceptar = botonAceptar;
	}

	public void setBotonCancelar(JButton botonCancelar) {
		this.botonCancelar = botonCancelar;
	}

	public void setBotonCerrar(JButton botonCerrar) {
		this.botonCerrar = botonCerrar;
	}

	public void setBotonMin(JButton botonMin) {
		this.botonMin = botonMin;
	}

	public void setFieldAlbum(JTextField fieldAlbum) {
		this.fieldAlbum = fieldAlbum;
	}

	public void setFieldAnyo(JTextField fieldAnyo) {
		this.fieldAnyo = fieldAnyo;
	}

	public void setFieldAutor(JTextField fieldAutor) {
		this.fieldAutor = fieldAutor;
	}

	public void setFieldGenero(JTextField fieldGenero) {
		this.fieldGenero = fieldGenero;
	}

	public void setFieldPista(JTextField fieldPista) {
		this.fieldPista = fieldPista;
	}

	public void setFieldTitulo(JTextField fieldTitulo) {
		this.fieldTitulo = fieldTitulo;
	}

	public void setLabelAlbum(JLabel labelAlbum) {
		this.labelAlbum = labelAlbum;
	}

	public void setLabelAnyo(JLabel labelAnyo) {
		this.labelAnyo = labelAnyo;
	}

	public void setLabelAutor(JLabel labelAutor) {
		this.labelAutor = labelAutor;
	}

	public void setLabelGenero(JLabel labelGenero) {
		this.labelGenero = labelGenero;
	}

	public void setLabelLogo(JLabel labelLogo) {
		this.labelLogo = labelLogo;
	}

	public void setLabelPista(JLabel labelPista) {
		this.labelPista = labelPista;
	}

	public void setLabelTitulo(JLabel labelTitulo) {
		this.labelLogo = labelTitulo;
	}

	public void setPanel(JPanelImagen panelTags) {
		this.panelTags = panelTags;
	}

	/**
	 * @param panelBotones
	 *            the panelBotones to set
	 */
	public void setPanelBotones(JPanelImagen panelBotones) {
		this.panelBotones = panelBotones;
	}

	public void setPanelSuperior(JPanelImagen panelSuperior) {
		this.panelSuperior = panelSuperior;
	}

	public void setPanelTags(JPanelImagen panelTags) {
		this.panelTags = panelTags;
	}

	public void setPanelVentana(JPanel panelVentana) {
		this.panelVentana = panelVentana;
	}

	public void setVentana(JFrame ventana) {
		this.ventana = ventana;
	}

	/*--- METODOS PUBLICOS ---*/
	public void show() {
		ventana.setVisible(true);
	}

	private void initComponents() {
		ventana = new JFrame();
		panelVentana = new JPanel();
		panelSuperior = new JPanelImagen("img/fondo_1100x60.png");
		labelLogo = new JLabel();
		botonMin = new JButton();
		botonCerrar = new JButton();
		panelTags = new JPanelImagen("img/fondo_400x400.png");
		labelAutor = new JLabel();
		fieldAutor = new JTextField();
		labelAlbum = new JLabel();
		fieldAlbum = new JTextField();
		labelTitulo = new JLabel();
		fieldTitulo = new JTextField();
		labelGenero = new JLabel();
		fieldGenero = new JTextField();
		labelAnyo = new JLabel();
		fieldAnyo = new JTextField();
		labelPista = new JLabel();
		fieldPista = new JTextField();
		panelBotones = new JPanelImagen("img/fondo_1100x60.png");
		botonAceptar = new JButton();
		botonCancelar = new JButton();

		/*--- DIMENSIONES DE PANELES EN FUNCION DE LA PANTALLA ---*/
		// w->width, h->height
		final Integer wPVentana, wPSuperior, wPTags, wPBotones;
		final Integer hPVentana, hPSuperior, hPTags, hPBotones;
		final String sWPVentana, sWPSuperior, sWPTags, sWPBotones;
		final String sHPVentana, sHPSuperior, sHPTags, sHPBotones;
		final Integer wCajas, hCajas;
		Integer wIzq, wDer, hSup, hCen, hInf; // Auxiliares

		// 0: Panel Ventana
		wPVentana = ancho;
		sWPVentana = wPVentana.toString() + "dlu";

		hPVentana = alto;
		hSup = new Integer((int) (hPVentana * 0.19)); // Panel superior
		hCen = new Integer((int) (hPVentana * 0.7)); // Panel Tags
		hInf = new Integer((int) (hPVentana * 0.105)); // Panel Botones
		sHPVentana = hSup.toString() + "dlu," + hCen.toString() + "dlu,"
				+ hInf.toString() + "dlu";

		// 1a: Panel Superior
		wPSuperior = wPVentana;
		wIzq = new Integer((int) (wPSuperior * 0.77)); // Logo
		wDer = new Integer((int) ((wPSuperior * 0.2) / 2)); // Tres botones
		sWPSuperior = wIzq.toString() + "dlu," + wDer.toString() + "dlu,"
				+ wDer.toString() + "dlu";

		hPSuperior = hSup;
		sHPSuperior = hPSuperior.toString() + "dlu";

		// 1b: Panel Tags
		wPTags = wPVentana;
		wCajas = new Integer((int) (wPTags * 1.2));
		wIzq = new Integer((int) (wPTags * 0.2)); // Labels
		wDer = new Integer((int) (wPTags * 0.8)); // Cajas
		sWPTags = wIzq.toString() + "dlu," + wDer.toString() + "dlu";

		hPTags = hCen;
		hSup = new Integer((int) (hPTags * 0.17)); // Cada fila
		hCajas = hSup;
		sHPTags = hSup.toString() + "dlu," + hSup.toString() + "dlu,"
				+ hSup.toString() + "dlu," + hSup.toString() + "dlu,"
				+ hSup.toString() + "dlu," + hSup.toString() + "dlu";

		// 1c: Panel botones
		wPBotones = wPVentana;
		wIzq = new Integer((int) (wPBotones / 2));
		sWPBotones = wIzq.toString() + "dlu," + wIzq.toString() + "dlu";

		hPBotones = hSup;
		sHPBotones = hPBotones.toString() + "dlu";

		// ======= Ventana =======
		ventana.setUndecorated(true); // Quita los botones del borde
		ventana.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
		ventana.setAlwaysOnTop(false);
		ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		Image icono = Toolkit.getDefaultToolkit().getImage(
				FormTags.class.getClassLoader().getResource(
						"img/iconoX_27x27.png"));
		ventana.setIconImage(icono);
		ventana.setTitle("Propiedades - XtremeAudio");
		Container ventanaContentPane = ventana.getContentPane();
		ventanaContentPane.setBackground(Color.black);
		ventanaContentPane.setLayout(new FormLayout(ancho.toString() + "dlu",
				alto.toString() + "dlu"));

		// ======== panelVentana ========
		{
			MoverPanelListener mml = new MoverPanelListener(panelVentana);
			panelVentana.addMouseListener(mml);
			panelVentana.addMouseMotionListener(mml);
			panelVentana
					.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
			panelVentana.setBackground(Color.black);
			panelVentana.setBorder(new LineBorder(colorBorde, 2, true));
			panelVentana.setLayout(new FormLayout(sWPVentana, sHPVentana));

			// ======== panelSuperior ========
			{
				panelSuperior.setBackground(new Color(255, 102, 0));
				panelSuperior.setBorder(new LineBorder(colorBorde, 2, true));
				panelSuperior
						.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
				panelSuperior
						.setLayout(new FormLayout(sWPSuperior, sHPSuperior));

				// ---- labelTitulo ----
				labelLogo.setIcon(new ImageIcon(FormTags.class.getClassLoader()
						.getResource("img/logo_313x50.png")));
				labelLogo
						.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
				labelLogo.setFocusable(false);
				panelSuperior.add(labelLogo, new CellConstraints(1, 1, 1, 1,
						CellConstraints.CENTER, CellConstraints.TOP,
						new Insets(5, 0, 0, 0)));

				// ---- botonMin ----
				botonMin.setIcon(new ImageIcon(FormTags.class.getClassLoader()
						.getResource("img/minimizar_45x45.png")));
				botonMin.setCursor(Cursor
						.getPredefinedCursor(Cursor.HAND_CURSOR));
				botonMin.setBackground(Color.black);
				botonMin.setToolTipText("Minimizar");
				botonMin.setFocusable(false);
				botonMin
						.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
				botonMin.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						botonMinActionPerformed(e);
					}

					private void botonMinActionPerformed(ActionEvent e) {
						Controlador.minimizarFormTags();
					}
				});
				panelSuperior.add(botonMin, new CellConstraints(2, 1, 1, 1,
						CellConstraints.CENTER, CellConstraints.TOP,
						new Insets(2, 0, 0, 0)));

				// ---- botonCerrar ----
				botonCerrar.setIcon(new ImageIcon(FormTags.class
						.getClassLoader().getResource("img/cerrar_45x45.png")));
				botonCerrar.setCursor(Cursor
						.getPredefinedCursor(Cursor.HAND_CURSOR));
				botonCerrar.setBackground(Color.black);
				botonCerrar.setToolTipText("Salir");
				botonCerrar.setFocusable(false);
				botonCerrar
						.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
				botonCerrar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						botonCerrarActionPerformed(e);
					}

					private void botonCerrarActionPerformed(ActionEvent e) {
						Controlador.cerrarFormTags();
					}
				});
				panelSuperior.add(botonCerrar, new CellConstraints(3, 1, 1, 1,
						CellConstraints.CENTER, CellConstraints.TOP,
						new Insets(2, 0, 0, 0)));
			}
			panelVentana.add(panelSuperior, new CellConstraints(1, 1, 1, 1,
					CellConstraints.FILL, CellConstraints.FILL, new Insets(3,
							2, 3, 6)));

			// ======== panelTags ========
			{
				panelTags.setBackground(new Color(255, 102, 0));
				panelTags.setBorder(new LineBorder(colorBorde, 2, true));
				panelTags
						.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
				panelTags.setLayout(new FormLayout(sWPTags, sHPTags));

				// label y field autor
				{
					labelAutor.setText("Int\u00e9rprete");
					labelAutor.setHorizontalAlignment(SwingConstants.LEFT);
					labelAutor.setForeground(Color.white);
					labelAutor.setFont(new Font(labelAutor.getFont().getName(),
							Font.BOLD, labelAutor.getFont().getSize() + 4));
				}
				panelTags.add(labelAutor, new CellConstraints(1, 1, 1, 1,
						CellConstraints.RIGHT, CellConstraints.CENTER));
				{
					fieldAutor.setBorder(new LineBorder(colorBorde, 2, true));
					fieldAutor.setPreferredSize(new Dimension(wCajas, hCajas));
					fieldAutor.setFont(new Font(fieldAutor.getFont().getName(),
							Font.BOLD, fieldAutor.getFont().getSize() + 2));
					fieldAutor.addFocusListener(new FocusAdapter() {

						public void focusGained(FocusEvent e) {
							fieldAutor.selectAll();
						}
					});

				}
				panelTags.add(fieldAutor, new CellConstraints(2, 1, 1, 1,
						CellConstraints.CENTER, CellConstraints.CENTER));

				// label y field album
				{
					labelAlbum.setText("\u00c1lbum");
					labelAlbum.setHorizontalAlignment(SwingConstants.LEFT);
					labelAlbum.setForeground(Color.white);
					labelAlbum.setFont(new Font(labelAlbum.getFont().getName(),
							Font.BOLD, labelAlbum.getFont().getSize() + 4));
				}
				panelTags.add(labelAlbum, new CellConstraints(1, 2, 1, 1,
						CellConstraints.RIGHT, CellConstraints.CENTER));
				{
					fieldAlbum.setBorder(new LineBorder(colorBorde, 2, true));
					fieldAlbum.setPreferredSize(new Dimension(wCajas, hCajas));
					fieldAlbum.setFont(new Font(fieldAlbum.getFont().getName(),
							Font.BOLD, fieldAlbum.getFont().getSize() + 2));
					fieldAlbum.addFocusListener(new FocusAdapter() {

						public void focusGained(FocusEvent e) {
							fieldAlbum.selectAll();
						}
					});
				}
				panelTags.add(fieldAlbum, new CellConstraints(2, 2, 1, 1,
						CellConstraints.CENTER, CellConstraints.CENTER));

				// label y field titulo
				{
					labelTitulo.setText("T\u00edtulo");
					labelTitulo.setHorizontalAlignment(SwingConstants.LEFT);
					labelTitulo.setForeground(Color.white);
					labelTitulo.setFont(new Font(labelTitulo.getFont()
							.getName(), Font.BOLD, labelTitulo.getFont()
							.getSize() + 4));
				}
				panelTags.add(labelTitulo, new CellConstraints(1, 3, 1, 1,
						CellConstraints.RIGHT, CellConstraints.CENTER));
				{
					fieldTitulo.setBorder(new LineBorder(colorBorde, 2, true));
					fieldTitulo.setPreferredSize(new Dimension(wCajas, hCajas));
					fieldTitulo.setFont(new Font(fieldTitulo.getFont()
							.getName(), Font.BOLD, fieldTitulo.getFont()
							.getSize() + 2));
					fieldTitulo.addFocusListener(new FocusAdapter() {

						public void focusGained(FocusEvent e) {
							fieldTitulo.selectAll();
						}
					});
				}
				panelTags.add(fieldTitulo, new CellConstraints(2, 3, 1, 1,
						CellConstraints.CENTER, CellConstraints.CENTER));

				// label y field genero
				{
					labelGenero.setText("G\u00e9nero");
					labelGenero.setHorizontalAlignment(SwingConstants.LEFT);
					labelGenero.setForeground(Color.white);
					labelGenero.setFont(new Font(labelGenero.getFont()
							.getName(), Font.BOLD, labelGenero.getFont()
							.getSize() + 4));
				}
				panelTags.add(labelGenero, new CellConstraints(1, 4, 1, 1,
						CellConstraints.RIGHT, CellConstraints.CENTER));
				{
					fieldGenero.setBorder(new LineBorder(colorBorde, 2, true));
					fieldGenero.setPreferredSize(new Dimension(wCajas, hCajas));
					fieldGenero.setFont(new Font(fieldGenero.getFont()
							.getName(), Font.BOLD, fieldGenero.getFont()
							.getSize() + 2));
					fieldGenero.addFocusListener(new FocusAdapter() {

						public void focusGained(FocusEvent e) {
							fieldGenero.selectAll();
						}
					});
				}
				panelTags.add(fieldGenero, new CellConstraints(2, 4, 1, 1,
						CellConstraints.CENTER, CellConstraints.CENTER));

				// label y field anyo
				{
					labelAnyo.setText("A\u00f1o");
					labelAnyo.setHorizontalAlignment(SwingConstants.LEFT);
					labelAnyo.setForeground(Color.white);
					labelAnyo.setFont(new Font(labelAnyo.getFont().getName(),
							Font.BOLD, labelAnyo.getFont().getSize() + 4));
				}
				panelTags.add(labelAnyo, new CellConstraints(1, 5, 1, 1,
						CellConstraints.RIGHT, CellConstraints.CENTER));
				{
					fieldAnyo.setBorder(new LineBorder(colorBorde, 2, true));
					fieldAnyo.setPreferredSize(new Dimension(wCajas, hCajas));
					fieldAnyo.setFont(new Font(fieldAnyo.getFont().getName(),
							Font.BOLD, fieldAnyo.getFont().getSize() + 2));
					fieldAnyo.addFocusListener(new FocusAdapter() {

						public void focusGained(FocusEvent e) {
							fieldAnyo.selectAll();
						}
					});
				}
				panelTags.add(fieldAnyo, new CellConstraints(2, 5, 1, 1,
						CellConstraints.CENTER, CellConstraints.CENTER));

				// label y field pista
				{
					labelPista.setText("Pista");
					labelPista.setHorizontalAlignment(SwingConstants.LEFT);
					labelPista.setForeground(Color.white);
					labelPista.setFont(new Font(labelPista.getFont().getName(),
							Font.BOLD, labelPista.getFont().getSize() + 4));
				}
				panelTags.add(labelPista, new CellConstraints(1, 6, 1, 1,
						CellConstraints.RIGHT, CellConstraints.CENTER));
				{
					fieldPista.setBorder(new LineBorder(colorBorde, 2, true));
					fieldPista.setPreferredSize(new Dimension(wCajas, hCajas));
					fieldPista.setFont(new Font(fieldPista.getFont().getName(),
							Font.BOLD, fieldPista.getFont().getSize() + 2));
					fieldPista.addFocusListener(new FocusAdapter() {

						public void focusGained(FocusEvent e) {
							fieldPista.selectAll();
						}
					});
				}
				panelTags.add(fieldPista, new CellConstraints(2, 6, 1, 1,
						CellConstraints.CENTER, CellConstraints.CENTER));
			}
			panelVentana.add(panelTags, new CellConstraints(1, 2, 1, 1,
					CellConstraints.FILL, CellConstraints.FILL, new Insets(3,
							2, 3, 6)));

			// ======== panelBotones ========
			{
				panelBotones.setBackground(new Color(255, 102, 0));
				panelBotones
						.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
				panelBotones.setLayout(new FormLayout(sWPBotones, sHPBotones));

				// ---- botonAceptar ----
				{
					botonAceptar.setText(" Aceptar ");
					botonAceptar.setCursor(Cursor
							.getPredefinedCursor(Cursor.HAND_CURSOR));
					botonAceptar.setBackground(Color.black);
					botonAceptar.setForeground(Color.white);
					botonAceptar.setFocusable(true);
					botonAceptar
							.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
					botonAceptar.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							botonAceptarActionPerformed(e);
						}

						private void botonAceptarActionPerformed(ActionEvent e) {
							Controlador.guardarTags();
						}
					});
				}
				panelBotones.add(botonAceptar, new CellConstraints(1, 1, 1, 1,
						CellConstraints.RIGHT, CellConstraints.TOP, new Insets(
								0, 0, 0, 6)));

				// ---- botonCancelar ----

				botonCancelar.setText("Cancelar");
				botonCancelar.setCursor(Cursor
						.getPredefinedCursor(Cursor.HAND_CURSOR));
				botonCancelar.setBackground(Color.black);
				botonCancelar.setForeground(Color.white);
				botonCancelar.setFocusable(true);
				botonCancelar
						.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
				botonCancelar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						botonCancelarActionPerformed(e);
					}

					private void botonCancelarActionPerformed(ActionEvent e) {
						Controlador.cerrarFormTags();
					}
				});
				panelBotones.add(botonCancelar, new CellConstraints(2, 1, 1, 1,
						CellConstraints.LEFT, CellConstraints.TOP));
			}
			panelVentana.add(panelBotones, new CellConstraints(1, 3, 1, 1,
					CellConstraints.FILL, CellConstraints.FILL, new Insets(3,
							2, 3, 5)));
		}
		ventanaContentPane.add(panelVentana, new CellConstraints(1, 1, 1, 1,
				CellConstraints.FILL, CellConstraints.FILL));
		ventana.pack();
		ventana.setLocationRelativeTo(null);
	}

	private void initLookAndFeel() {
		// Establece el Look&Feel
		UIManager.put("nimbusBase", new Color(245, 94, 0));
		try {
			for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
				if ("Nimbus".equals(info.getName())) {
					UIManager.setLookAndFeel(info.getClassName());
					break;
				}
			}
		} catch (Exception e) {
			try {
				UIManager.setLookAndFeel(UIManager
						.getSystemLookAndFeelClassName());
			} catch (ClassNotFoundException e1) {
				e1.printStackTrace();
			} catch (InstantiationException e1) {
				e1.printStackTrace();
			} catch (IllegalAccessException e1) {
				e1.printStackTrace();
			} catch (UnsupportedLookAndFeelException e1) {
				e1.printStackTrace();
			}
		}

		// Obtiene las dimensiones de la pantalla
		Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
		if (((float) screen.width / (float) screen.height) > 1.25) { // Panoramica
			ancho = new Integer((int) (screen.width / 4.5));
			alto = new Integer((int) (screen.height / 3.4));
		} else {
			ancho = new Integer((int) (screen.width / 4.5));
			alto = new Integer((int) (screen.height / 4.5));
		}
	}

}